package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@ToString
public class Customer {
    public final static Integer status_common = 0;//潜在客户
    public final static Integer status_pool = 1;//客户池客户
    public final static Integer status_fail = 2;//失败客户
    public final static Integer status_formal = 3;//正式客户
    public final static Integer status_lost = 4;//流失客户

    private Long id;//客户id
    private String name;//客户名字
    private Integer age;//年龄
    private Integer gender;//性别
    private String tel;//电话
    private String qq;//qq
    private SystemDictionaryItem job;
    private SystemDictionaryItem source;
    private Employee seller;
    private Employee inputUser;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date inputTime;
    private Integer status=0;


    public String getJson(){
        Map<String,Object> map =  new HashMap<String,Object>();
        map.put("id",this.id);
        map.put("name",this.name);
        map.put("age",this.age);
        map.put("gender",this.gender);
        map.put("tel",this.tel);
        map.put("qq",this.qq);
        map.put("jobId",this.job.getId());
        map.put("sourceId",this.source.getId());
        map.put("inputTime",this.inputTime);
        map.put("inputUser",this.inputUser);
        map.put("seller",this.seller);
        map.put("status",this.status);
        return JSON.toJSONString(map);
    }


    public String getStatusName(){
        if (status == Customer.status_pool){
            return "客户池客户";
        }else if (status == Customer.status_fail){
            return "失败客户";
        }else if (status == Customer.status_formal){
            return "正式客户";
        }else if (status == Customer.status_lost){
            return "流失客户";
        }else{
            return "潜在客户";
        }
    }
}